<?php echo $this->Html->script('jquery.autogrow-textarea'); ?>

<?php
        
	echo $this->Form->create('Message', array( 'action' => 'sent', 'id' => 'message_form'));
        ?>
       
        <select id="receiver_id" name="data[Message][receiver_id]">
            <?php
                echo '<option value="0">'.__('Select friend', true).'</option>';
                foreach($sentTo as $to){
                    echo '<option value="'.$to['user_id'].'">'.$to['username'].'</option>';
                }
            ?>

        </select>
        <?php
        
        //echo $this->Form->input('title', array('label' => __('Title', true), 'id' => 'title'));
        echo $this->Html->tag('label', __('Message', true), array('for' => 'message'));
	echo $this->Form->input( 'message', array( 'label' => false, 'classs' => 'noticemessage', 'id' => 'message' ));
	echo $this->Html->div('button-sent',
                
                $this->Form->button('Sent',
			array(
                            'type' => 'button',
                            'class' => 'submit white',
                            'id' => 'button-sent'
			))
                );
	echo $this->Form->end();
?>
<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function () {
        //auto resize textarea
        $('textarea').autogrow();


        $("#button-sent").bind("click", function (event) {
             if($('#receiver_id').val() == 0){
                 $.jGrowl('<?php __('Please select a friend');?>');
                return false;
             /*}else if($('#title').val().length < 1){
                 $.jGrowl('<?php //__('Title cannot blank!');?>');
            */}else if($('#message').val().length < 1){
                $.jGrowl('<?php __('Message cannot blank!');?>');
                return false;
            }else{
                $('#message_form').submit();
            }
        });
    });
    //]]>
</script>
